package com.evildevil.engines.bubble.texture;

import java.util.Objects;

/* loaded from: DDSurfaceDesc2.class */
final class DDSurfaceDesc2 implements DDSurface {
    private DDPixelFormat pixelFormat;
    private DDSCaps2 caps2;
    private final String DDS_IDENTIFIER = "DDS ";
    protected long identifier = 0;
    private String identifierString = "";
    protected long size = 0;
    protected long flags = 0;
    protected long height = 0;
    protected long width = 0;
    protected long pitchOrLinearSize = 0;
    protected long depth = 0;
    protected long mipMapCount = 0;
    protected long reserved = 0;
    protected int reserved2 = 0;

    public DDSurfaceDesc2() {
        this.pixelFormat = null;
        this.caps2 = null;
        this.pixelFormat = new DDPixelFormat();
        this.caps2 = new DDSCaps2();
    }

    public void setIdentifier(long j) throws TextureFormatException {
        this.identifier = j;
        createIdentifierString();
    }

    private void createIdentifierString() throws TextureFormatException {
        this.identifierString = new String(new byte[]{(byte) this.identifier, (byte) (this.identifier >> 8), (byte) (this.identifier >> 16), (byte) (this.identifier >> 24)});
        String str = this.identifierString;
        Objects.requireNonNull(this);
        if (!str.equalsIgnoreCase("DDS ")) {
            throw new TextureFormatException("The DDS Identifier is wrong. Have to be \"DDS \"!");
        }
    }

    public void setSize(long j) throws TextureFormatException {
        if (j != 124) {
            throw new TextureFormatException("Wrong DDSurfaceDesc2 size. DDSurfaceDesc2 size must be 124!");
        }
        this.size = j;
    }

    public void setFlags(long j) throws TextureFormatException {
        this.flags = j;
        if ((j & 1) != 1 || (j & 4096) != 4096 || (j & 4) != 4 || (j & 2) != 2) {
            throw new TextureFormatException("One or more required flag bits are set wrong\nflags have to include \"DDSD_CAPS, DDSD_PIXELFORMAT, DDSD_WIDTH, DDSD_HEIGHT\"");
        }
    }

    public void setHeight(long j) {
        this.height = Math.abs(j);
    }

    public void setWidth(long j) {
        this.width = j;
    }

    public void setPitchOrLinearSize(long j) {
        this.pitchOrLinearSize = j;
        this.pitchOrLinearSize = ((this.width + 3) / 4) * ((this.height + 3) / 4) * 16;
        if (this.pitchOrLinearSize > 1000000) {
            this.pitchOrLinearSize = ((this.width + 3) / 4) * ((this.height + 3) / 4) * 16;
        }
    }

    public void setDepth(long j) {
        this.depth = j;
    }

    public void setMipMapCount(long j) {
        this.mipMapCount = j;
    }

    public void setDDPixelFormat(DDPixelFormat dDPixelFormat) throws NullPointerException {
        if (dDPixelFormat == null) {
            throw new NullPointerException("DDPixelFormat can't be null. DDSurfaceDesc2 needs a valid DDPixelFormat.");
        }
        this.pixelFormat = dDPixelFormat;
    }

    public DDPixelFormat getDDPixelformat() {
        return this.pixelFormat;
    }

    public void setDDSCaps2(DDSCaps2 dDSCaps2) throws NullPointerException {
        if (dDSCaps2 == null) {
            throw new NullPointerException("DDSCaps can't be null. DDSurfaceDesc2 needs a valid DDSCaps2.");
        }
        this.caps2 = dDSCaps2;
    }

    public DDSCaps2 getDDSCaps2() {
        return this.caps2;
    }
}